package com.travel.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.travel.entity.dto.ListResultVO;
import com.travel.entity.dto.ResultVO;
import com.travel.entity.goodsEn.TravelGoods;
import com.travel.entity.shop.TravelShop;
import com.travel.goods.mapper.TravelGoodsMapper;
import com.travel.goods.service.ITravelGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author muzi
 * @since 2021-04-14
 */
@Service
public class TravelGoodsServiceImpl extends ServiceImpl<TravelGoodsMapper, TravelGoods> implements ITravelGoodsService {

    @Autowired(required = false)
    private TravelGoodsMapper travelGoodsMapper;

    @Override
    public ResultVO findListByTypeId(String typeId) {


        List<TravelGoods> travelGoods = travelGoodsMapper.selectListByTypeId(typeId);

        if (travelGoods != null){
            return new ResultVO(true,"类型查询成功",travelGoods);
        }

        return new ResultVO(false,"类型查询失败");
    }

    @Override
    public ListResultVO<TravelGoods> findListByShopId(String shopId) {



        QueryWrapper<TravelGoods> queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("shop_id",shopId);

        List<TravelGoods> goodsList = travelGoodsMapper.selectList(queryWrapper);

        if(goodsList != null){
            return new ListResultVO<TravelGoods>(true,"success",goodsList);
        }

        return new ListResultVO(false,"fail",null);
    }


    @Override
    public ResultVO findAllGoods() {

       List<TravelGoods> travelGoodsList = travelGoodsMapper.selectAllGoods();

       if (travelGoodsList != null){
           return new ResultVO(true,"查询所有的商品属性成功",travelGoodsList);
       }

       return new ResultVO(false,"查询所有的商品属性失败");
    }

    @Override
    public List<TravelGoods> findListBySpuId(String supId) {

       List<TravelGoods> travelGoodsList = travelGoodsMapper.selectListBySpuId(supId);

       if (travelGoodsList != null){
           return travelGoodsList;
       }

        return null;

    }


}
